import { createApp } from "vue";
import { createPinia } from "pinia";
import router from "./router";
import App from "./App.vue";
import "./assets/main.css";
// 引入国际化语音包
import { i18n } from "@/i18n";
// pinia状态管理刷新不会丢失数据，引入组件
import PiniaPluginPersistedstate from "pinia-plugin-persistedstate";
//引入element-plus样式表
import "element-plus/dist/index.css"
// 全局引入动态路由
import "@/router/dynamicAddRouter"
// 友好日期全局引入
import '@/utils/friendlydate'
import 'nprogress/nprogress.css'
import { useUserStore } from "./stores/admin";
const pinia = createPinia()
pinia.use(PiniaPluginPersistedstate)

const app = createApp(App);
// 进行注册
app.use(i18n);
app.use(pinia);
app.use(router);

app.mount("#app");
// 自定义指令
app.directive("direct", {
    mounted(el, binding) {
        const store = useUserStore()
        const { perms } = store.user //获取存储在状态管理的个人信息
        const value = binding.value //获取的属性节点
        // 检索是否存在该属性
        var index = perms.findIndex(item => item == value)
        // 如果没有最直接移除
        if (-1 == index) {
            el.remove()
        }
    }
})